﻿@page
@model GoodToCode.Entity.Person.CreateModel

@using GoodToCode.Extensions
@using GoodToCode.Entity.WebApp
@using GoodToCode.Entity.Person

<h1>Create</h1>

<h4>Create a new Person</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form method="post">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Person.FirstName" class="control-label"></label>
                <input asp-for="Person.FirstName" class="form-control" />
                <span asp-validation-for="Person.FirstName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Person.LastName" class="control-label"></label>
                <input asp-for="Person.LastName" class="form-control" />
                <span asp-validation-for="Person.LastName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Person.BirthDate" class="control-label"></label>
                <input type="date" asp-for="Person.BirthDate" placeholder="YYYY-MM-DD" value="@(Model.Person.BirthDate == Defaults.Date ? Defaults.String : Model.Person.BirthDate.ToString("yyyy-MM-dd"))" class="form-control" />
                <span asp-validation-for="Person.BirthDate" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Person.GenderCode" class="control-label"></label>
                <select asp-for="Person.GenderCode" class="form-control" asp-items="@(new SelectList(GenderList.GetAll(), "Item2", "Item3", Model.Person.GenderCode))"></select>
            </div>
            <div class="form-group">
                <input type="submit" value="Create" class="btn btn-primary" />
            </div>
        </form>
        <div class="row">
            <div class="col-xs-offset-1 col-xs-10 ">
                @if (!ViewData.ModelState.IsValid)
                {
                    @Html.ValidationSummary(false, "Action resulted in...", new { @class = "text-danger" })
                }
                else
                {
                    <p class="text-info">@TempData[CreateModel.ResultMessage]</p>
                }
            </div>
        </div>
    </div>
</div>

<div>
    <a asp-page="Index">Back to List</a>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
